//
//  BaseNavigationController.swift
//

import UIKit

class BaseNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if children.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: true)
    }
    
    override func popToRootViewController(animated: Bool) -> [UIViewController]? {
        // 解决iOS 14 popToRootViewController tabbar不自动显示问题
        if #available(iOS 14, *), animated, let popController = viewControllers.last {
            popController.hidesBottomBarWhenPushed = false
        }
        return super.popToRootViewController(animated: animated)
    }

}
